import http from "@/api";
import { ResPage, OrgManager } from "@/api/interface/index";
import qs from "qs";
/**
 * @name 坐席模块
 */
// 分页查询未接电话
export const findCallLogPage = (params: {}, header: string, unhandle: string[]) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      if (unhandle.length > 0) {
        if (unhandle.includes(`${key}`)) {
          newobj[`${key}`] = `${params[key]}`;
        } else {
          newobj[header + "." + `${key}`] = `${params[key]}`;
        }
      } else {
        newobj[header + "." + `${key}`] = `${params[key]}`;
      }
    });
  } else {
    newobj = params;
  }
  return http.post(`/pages/callLog!findCallLogPage.action`, qs.stringify(newobj));
};

// 回访客户
export const updateFollowStatusByIds = (params: string) => {
  return http.post<String>(`/pages/callLog!updateFollowStatusByIds.action` + params, qs.stringify({})); // post 请求携带表单参数  ==>  application/x-www-form-urlencoded
};

//校验并保存
export const saveAndCheck = (params: {}, header: string) => {
  let newobj = {};
  if (header != null && header != "") {
    Object.keys(params).forEach(key => {
      newobj[header + "." + `${key}`] = `${params[key]}`;
    });
  }
  return http.post<String>(`/pages/ppbxToken!saveAndCheck.action`, qs.stringify(newobj)); // post 请求携带表单参数  ==>  application/x-www-form-urlencoded
};
// 获取ppbx账户密码
export const getPpbxIpAndPortUsernamePassword = () => {
  return http.post(`ppbxToken!getPpbxIpAndPortUsernamePassword.action`, qs.stringify({}), { loading: false });
};
